package org.tea.inventory.admin.web.sys;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.tea.inventory.base.util.ResponseUtil;
import org.tea.inventory.dao.sys.DepartmentInfoMapper;
import org.tea.inventory.dao.sys.DhrmCompanyMapper;
import org.tea.inventory.domain.sys.DepartmentInfo;
import org.tea.inventory.domain.sys.DhrmCompany;
import org.tea.inventory.service.IUserInfoService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author hanzy
 * @description
 * @date 2023年04月06日 17:33
 */
@Api(tags = "用户管理器")
@RestController
@RequestMapping("/admin/sys/user")
@RequiredArgsConstructor
public class SysUserController {


    private final IUserInfoService userInfoService;

    private final DepartmentInfoMapper departmentInfoMapper;

    private final DhrmCompanyMapper dhrmCompanyMapper;

    @PostMapping("getAll")
    @ApiOperation(value = " 获取所有用户(排除已删除的)")
    public Object getAll() {
        return ResponseUtil.ok(userInfoService.searchAllUsers());
    }

    @PostMapping("getDepts")
    @ApiOperation(value = " 获取所有部门")
    public Object depts() {
        List<DepartmentInfo> depts = departmentInfoMapper.selectAllCostCenter("69964c94aef84d3ea9d496a01188cbd8");
        return ResponseUtil.ok(depts);
    }

    @PostMapping("getCompanys")
    @ApiOperation(value = " 获取所有公司主体")
    public Object companys() {
        List<DhrmCompany> depts = dhrmCompanyMapper.querydhrmCompany();
        return ResponseUtil.ok(depts);
    }
}
